package com.j.lemon.learn.thread.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author lijunjun
 * @Date 2019-04-22 18:04
 * @Description
 */
public class CallableDemo implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        return 1024;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<>(new CallableDemo());
        Thread thread = new Thread(futureTask);
        thread.start();
        Integer integer = futureTask.get();
        System.out.println(integer);
    }
}
